home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1988 April / Ahoy_Magazine_88-04_1988_Double_L.d64 / Coin Challenge (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  724b  |  24 lines

  1. 1 rem ==================================
  2. 2 rem    commodares problem #48-1 :
  3. 3 rem     coin challenge
  4. 4 rem    solution by
  5. 5 rem     don donati
  6. 6 rem ==================================
  7. 90 print"[147]"
  8. 100 c$(1)="pennies":v%(1)=1:c$(2)="nickels":v%(2)=5:c$(3)="dimes":v%(3)=10
  9. 110 c$(4)="quarters":v%(4)=25:c$(5)="half-dollars":v%(5)=50:tt%=0:print"[147]"
  10. 120 for i=1 to 5
  11. 125 printtab(13)"coin challenge"
  12. 130 print c$(i);:input n%:if n%<0 then 130
  13. 140 tt%=tt%+n%*v%(i):next i
  14. 150 print:print"total: $";tt%/100
  15. 160 on sgn(tt%-100)+2 goto 170, 180, 190
  16. 170 print"less than a dollar":print "add:":goto 200
  17. 180 print"equal to a dollar": end
  18. 190 print"greater than a dollar":print"remove:"
  19. 200 df%=abs(tt%-100)
  20. 210 for i=5 to 1 step -1
  21. 220 c%=df%/v%(i):if c%=0 then 240
  22. 230 df%=df%-c%*v%(i): print c%;c$(i)
  23. 240 next i : end
  24.